import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String[] args) {
        BigDecimal bd = BigDecimal.valueOf(0.1);
        double a = 0.1;
        double b = 0.2;
        double c = a+b;
        System.out.println(c);

        BigDecimal a1 = BigDecimal.valueOf(a);
        BigDecimal b1 = BigDecimal.valueOf(b);
        BigDecimal c1 = a1.add(b1);//加
        BigDecimal c2 = a1.subtract(b1);//减
        BigDecimal c3 = a1.multiply(b1);//乘
        BigDecimal c4 = a1.divide(b1);//除
        System.out.println(c1);
        System.out.println(c2);
        System.out.println(c3);
        System.out.println(c4);

        double rs1 = c1.doubleValue();
        double rs2 = c2.doubleValue();
        double rs3 = c3.doubleValue();
        double rs4 = c4.doubleValue();

        System.out.println(rs1);
        System.out.println(rs2);
        System.out.println(rs3);
        System.out.println(rs4);

        BigDecimal a11 = BigDecimal.valueOf(10.0);
        BigDecimal b11 = BigDecimal.valueOf(3.0);
        BigDecimal c11 = a11.divide(b11,3,RoundingMode.HALF_UP);
        System.out.println(c11);
    }
}
